<?php
$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('home', 'order_management');
$this->breadcrumbs = array(
    Yii::t('home', 'order_management')
);

$baseUrl = Yii::app()->getBaseUrl(true);

if (Yii::app()->user->isGuest || Yii::app()->user->id != SpecialUser::ADMIN_ID) {
    $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
        'id' => 'mydialog',
        // additional javascript options for the dialog plugin
        'options' => array(
            'title' => Yii::t('home', 'message'),
            'autoOpen' => true,
            'modal' => true,
            'beforeClose' => 'js:function(){window.location = "' . $baseUrl . '/index.php?r=index";}',
            'buttons' => array(
                Yii::t('home', 'close') => 'js:function(){window.location = "' . $baseUrl . '/index.php?r=login";}'
            ),
        ),
    ));

    echo Yii::t('home', 'require_login');

    $this->endWidget('zii.widgets.jui.CJuiDialog');
    return;
}
?>
<div id="focus" class="wrapper row100 bgded" style="background-image:url('images/live-demo/background-03.jpg');">
    <div class="overlay">
        <div id="grid-box" class="clear center">
            <h2 class="uppercase font-x3 btmspace-50"><?= Yii::t('ordermanagement', 'order_management') ?></h2>

            <?php
            $this->widget('zii.widgets.grid.CGridView', array(
                'dataProvider' => $model->searchForward(),
                'summaryText' => Yii::t('home', 'summaryText'),
                'filter' => $model,
                'columns' => array(
                    array(
                        'name' => 'order_id',
                        'htmlOptions' => array('style' => 'text-align: center;'),
                        'filterHtmlOptions' => array('style' => 'width: 100px;'),
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'cust_id',
                        'value' => '$data->customer->Name." ".$data->customer->Surname',
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'status_id',
                        'value' => '$data->status->name',
                        'type' => 'raw',
                        'filter' => false,
                    ),
                    array(
                        'name' => 'name',
                        'filter' => false
                    ),
                    array(
                        'name' => 'surname',
                        'filter' => false
                    ),
                    array(
                        'name' => 'price',
                        'value' => '$data->price',
                        'filter' => false
                    ),
                    array(
                        'name' => 'create_date',
                        'value' => 'ConvertFormatUtil::getDateLocale($data->create_date, Yii::app()->language)',
                        'filter' => false
                    ),
                    array(
                        'header' => Yii::t('ordermanagement', 'forward'),
                        'class' => 'CButtonColumn',
                        'filterHtmlOptions' => array('style' => 'width: 60px;'),
                        'template' => '{view} {forward}',
                        'buttons' => array(
                            'forward' => array(
                                'label' => 'Forward order to master',
                                'imageUrl' => Yii::app()->request->baseUrl . '/images/forward_16.png',
                                'url' => 'Yii::app()->createUrl("ordermanagement/forward", array("id"=>$data->order_id))',
                                'visible' => '$data->status_id == 3',
                                'options' => array(
                                    'onClick' => 'js:if(confirm("' . Yii::t('ordermanagement', 'order_forward') . '")) {return true;} return false;'
                                ),
                            )
                        ),
                    ),
                ),
            ));
            ?>
        </div>
    </div>
</div>